import BaseXform from '../../base-xform';

class VmlProtectionXform extends BaseXform {
    constructor(model) {
        super();
        this._model = model;
    }

    get tag() {
        return this._model && this._model.tag;
    }

    render(xmlStream, model) {
        xmlStream.leafNode(this.tag, null, model);
    }

    parseXmlObject(node) {
        if (node._name === this.tag) {
            //数据存储在节点
            this.text = "";
            node._elements.forEach((item) => {
                this.text = item._text
            })
            this.model = this.text

            return true
        }
        return false
    }

    parseOpen(node) {
        switch (node.name) {
            case this.tag:
                this.text = '';
                return true;
            default:
                return false;
        }
    }

    parseText(text) {
        this.text = text;
    }

    parseClose() {
        return false;
    }
}

export default VmlProtectionXform;
